home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2006 May / PCWMAY06.iso / Software / Freeware / First Page 2006 3.00 / fp2006-final-3.00-setup.exe / {app} / Iscripts / Maths & Calculations / javascript-graph.izs < prev    next >
Text File  |  2005-07-29  |  6KB  |  155 lines

  1. <!NOWIZARD>
  2.  
  3. <!TITLE>Quadratic calculator
  4. <!/TITLE>
  5.  
  6. <!DESCRIPTION>Solve quadratic equations with ease using this Math script!
  7. <!/DESCRIPTION> 
  8.  
  9. <!CATEGORY>math related<!/CATEGORY>
  10.  
  11. <!SCRIPT>
  12. <!-- START OF SCRIPT -->
  13. <SCRIPT language="JavaScript">
  14. <!--
  15.  
  16. //Quadratic Calculator, by Taydron
  17. //http://www.taydron-domain.net
  18.  
  19.  
  20. function quadData1() {
  21. var valA = document.quadCalc.valA.value;
  22. var valB = document.quadCalc.valB.value;
  23. var valC = document.quadCalc.valC.value;
  24. var disc = (valB*valB)-(4*valA*valC);
  25. var r_disc = Math.sqrt(disc);
  26. var vax1 = (-valB+r_disc)/(2*valA);
  27. var vax2 = (-valB-r_disc)/(2*valA);
  28. var ing1 = ((valA*vax1*vax1*vax1)/3)+((valB*vax1*vax1)/2)+(valC*vax1);
  29. var ing2 = ((valA*vax2*vax2*vax2)/3)+((valB*vax2*vax2)/2)+(valC*vax2);
  30. var inte = ing1-ing2;
  31. var sec_dx = (-valB)/(2*valA);
  32. var sec_dy = (valA*sec_dx*sec_dx)+(valB*sec_dx)+(1*valC);
  33. var e_val;
  34. vax1 = Math.round(vax1*100)/100;
  35. vax2 = Math.round(vax2*100)/100;
  36. inte = Math.round(inte*100)/100;
  37. sec_dx = Math.round(sec_dx*100)/100;
  38. sec_dy = Math.round(sec_dy*100)/100;
  39. if (valA == 0) {document.quadCalc.answer1.value = "This curve is not a quadratic. Enter a non-zero value in the first box.";} 
  40.  else {
  41.  if (disc>0) {
  42.   document.quadCalc.answer1.value = "The curve intercepts the x-axis at: " +vax1+ " and " +vax2+ ".";
  43.    {
  44.    if (inte>0) {document.quadCalc.answer2.value = inte;} 
  45.    if (inte<0) {document.quadCalc.answer2.value = -inte;} 
  46.    if (inte=0) {document.quadCalc.answer2.value = 0;}
  47.    }
  48.   } if (disc<0) {
  49.   document.quadCalc.answer1.value = "The curve has no real roots, because it does not intercept the real x-axis.";
  50.   document.quadCalc.answer2.value = "N/A";
  51.   } if (disc=0) {
  52.   document.quadCalc.answer1.value = "The curve touches the x-axis at: " +vax1+ ".";
  53.   document.quadCalc.answer2.value = "N/A";
  54.   }
  55.  document.quadCalc.answer3.value = (2*valA)+ "x+" +valB;
  56.  if (valA<0) {e_val = "maximum";} 
  57.  if (valA>0) {e_val = "minimum";} 
  58.  document.quadCalc.answer4.value = e_val;
  59.  document.quadCalc.answer5.value = sec_dx+ " , " +sec_dy;
  60.   }
  61.  }
  62. //-->
  63. </SCRIPT>
  64.  
  65. <b>Quadratic Calculator</b>
  66. <form name="quadCalc">
  67. <font color="000000" face="Rockwell" size="-1">
  68. A quadratic is a curve of the parabola family.<br>
  69. They are written in the format ax<sup>2</sup>+bx+c=0.<br><br>
  70. <input type="text" maxlength="8" name="valA" value="8" size="4">x<sup>2</sup>+
  71. <input type="text" maxlength="8" name="valB" value="10" size="4">x+
  72. <input type="text" maxlength="8" name="valC" value="2" size="4">=0<br>
  73. <input type="button" onClick=quadData1() value="Calculate"> <input type="reset" value="Reset"><br>
  74. <input type="text" name="answer1" readonly="readonly" size="60"><br>
  75. The area bounded by the curve above the x-axis is: <input type="text" name="answer2" readonly="readonly" size="6"> sq. units.<br>
  76. The gradient of the curve at any point is: <input type="text" name="answer3" size="10">.<br>
  77. The <input type="text" name="answer4" readonly="readonly" size="8"> value of the curve occurs at co-ordinates: <input type="text" name="answer5" readonly="readonly" size="10">.</font>
  78. </form>
  79.  
  80.  
  81. <!-- END OF SCRIPT -->
  82. <!/SCRIPT>
  83.  
  84. <!PREVIEW>
  85. <!-- START OF SCRIPT --><SCRIPT language="JavaScript">
  86. <!--
  87.  
  88. //Quadratic Calculator, by Taydron
  89. //http://www.taydron-domain.net
  90.  
  91.  
  92. function quadData1() {
  93. var valA = document.quadCalc.valA.value;
  94. var valB = document.quadCalc.valB.value;
  95. var valC = document.quadCalc.valC.value;
  96. var disc = (valB*valB)-(4*valA*valC);
  97. var r_disc = Math.sqrt(disc);
  98. var vax1 = (-valB+r_disc)/(2*valA);
  99. var vax2 = (-valB-r_disc)/(2*valA);
  100. var ing1 = ((valA*vax1*vax1*vax1)/3)+((valB*vax1*vax1)/2)+(valC*vax1);
  101. var ing2 = ((valA*vax2*vax2*vax2)/3)+((valB*vax2*vax2)/2)+(valC*vax2);
  102. var inte = ing1-ing2;
  103. var sec_dx = (-valB)/(2*valA);
  104. var sec_dy = (valA*sec_dx*sec_dx)+(valB*sec_dx)+(1*valC);
  105. var e_val;
  106. vax1 = Math.round(vax1*100)/100;
  107. vax2 = Math.round(vax2*100)/100;
  108. inte = Math.round(inte*100)/100;
  109. sec_dx = Math.round(sec_dx*100)/100;
  110. sec_dy = Math.round(sec_dy*100)/100;
  111. if (valA == 0) {document.quadCalc.answer1.value = "This curve is not a quadratic. Enter a non-zero value in the first box.";} 
  112.  else {
  113.  if (disc>0) {
  114.   document.quadCalc.answer1.value = "The curve intercepts the x-axis at: " +vax1+ " and " +vax2+ ".";
  115.    {
  116.    if (inte>0) {document.quadCalc.answer2.value = inte;} 
  117.    if (inte<0) {document.quadCalc.answer2.value = -inte;} 
  118.    if (inte=0) {document.quadCalc.answer2.value = 0;}
  119.    }
  120.   } if (disc<0) {
  121.   document.quadCalc.answer1.value = "The curve has no real roots, because it does not intercept the real x-axis.";
  122.   document.quadCalc.answer2.value = "N/A";
  123.   } if (disc=0) {
  124.   document.quadCalc.answer1.value = "The curve touches the x-axis at: " +vax1+ ".";
  125.   document.quadCalc.answer2.value = "N/A";
  126.   }
  127.  document.quadCalc.answer3.value = (2*valA)+ "x+" +valB;
  128.  if (valA<0) {e_val = "maximum";} 
  129.  if (valA>0) {e_val = "minimum";} 
  130.  document.quadCalc.answer4.value = e_val;
  131.  document.quadCalc.answer5.value = sec_dx+ " , " +sec_dy;
  132.   }
  133.  }
  134. //-->
  135. </SCRIPT>
  136.  
  137. <b>Quadratic Calculator</b>
  138. <form name="quadCalc">
  139. <font color="000000" face="Rockwell" size="-1">
  140. A quadratic is a curve of the parabola family.<br>
  141. They are written in the format ax<sup>2</sup>+bx+c=0.<br><br>
  142. <input type="text" maxlength="8" name="valA" value="8" size="4">x<sup>2</sup>+
  143. <input type="text" maxlength="8" name="valB" value="10" size="4">x+
  144. <input type="text" maxlength="8" name="valC" value="2" size="4">=0<br>
  145. <input type="button" onClick=quadData1() value="Calculate"> <input type="reset" value="Reset"><br>
  146. <input type="text" name="answer1" readonly="readonly" size="60"><br>
  147. The area bounded by the curve above the x-axis is: <input type="text" name="answer2" readonly="readonly" size="6"> sq. units.<br>
  148. The gradient of the curve at any point is: <input type="text" name="answer3" size="10">.<br>
  149. The <input type="text" name="answer4" readonly="readonly" size="8"> value of the curve occurs at co-ordinates: <input type="text" name="answer5" readonly="readonly" size="10">.</font>
  150. </form>
  151.  
  152. <!-- END OF SCRIPT -->
  153. <!/PREVIEW>
  154.  
  155. <!RELATED>NONE<!/RELATED>